import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

import { resolve } from 'path'

import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vite.dev/config/
export default defineConfig({
  server:{
    "proxy":{
      // "/apicaptcha":{
      //   target:'http://uat.crm.xuexiluxian.cn', 
      //   changeOrigin:true,
      //   rewrite: path =>  path.replace(/^\/api/,'')
      // },
      "/api":{
        // target:'http://uat.crm.xuexiluxian.cn', 
        // target:'http://uat.admin.banlu.xuexiluxian.cn',
        // target:'http://uat.admin.banlu.xuexiluxian.cn/api',
        target:'http://uat.admin.banlu.xuexiluxian.cn/api',
        // target:'http://uat.banlu.xuexiluxian.cn',
        changeOrigin:true,
        rewrite: path =>  path.replace(/^\/api/,'')
      },
    }
  },
  resolve:{
    alias:{
      '@store': resolve('src/store'),
      '@views': resolve('src/views'),
      '@router': resolve('src/router'),
      '@components': resolve('src/components'),
      '@utils': resolve('src/utils'),
      '@api': resolve('src/api'),
      '@layouts': resolve('src/layouts'),
    }
  },
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
})
